<?php
namespace app\admin\controller;
use think\Db;
class Common extends Base{
    //设置
    public function system_set(){
        if(request()->isGet()){
            $param = input('get.');
            $data=Db::name('system_set')->where('id',1)->find();
            $this->assign('data',$data);
            return $this->fetch();
        }elseif(request()->isPost()){
            $param = input('post.');
            $data['company']=$param['company'];
            $data['self_stores']=$param['self_stores'];
            $data['buy_score']=$param['buy_score'];
            $data['server_tel']=$param['server_tel'];
            $data['server_qq']=$param['server_qq'];
            $data['sign_score']=$param['sign_score'];
            $data['score_rule']=$param['score_rule'];
            $data['tips']=$param['tips'];
            $data['protocol']=$param['protocol'];
            $data['introduce']=$param['introduce'];
            $data['free_limit']=$param['free_limit'];
            $data['distance']=$param['distance'];
            $data['longitude_latitude']=$param['longitude_latitude'];
            $data['uptime'] =time();
            $res= Db::name('system_set')->where(array('id'=>1))->update($data);
            if($res){
                return json(['code' => 200,'msg' => '更新成功']);
            }else{
                return json(['code' => 500,'msg' => '失败']);
            }
        }
    }
}
